﻿Namespace Compiler.Semantic

    ''' <summary>
    ''' A basic unit used to identify one type, memeber or variable. 
    ''' </summary>
    ''' <remarks>
    ''' This is mainly used in type or method overloading.
    ''' For example: class A(Of T) and class A are different classes, but they have the same name. There will be two binders to identify
    ''' them. 
    ''' </remarks>
    Public MustInherit Class Binder
        Implements IEquatable(Of Binder)

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            If obj Is Nothing Then Return False
            If Not TypeOf obj Is Binder Then Return False

            Return Equals(TryCast(obj, Binder))
        End Function

        Public MustOverride Overrides Function GetHashCode() As Integer

        Public Shared Operator =(ByVal a As Binder, ByVal b As Binder) As Boolean
            If a Is Nothing Then
                If b Is Nothing Then Return True Else Return False
            End If
            Return a.Equals(b)
        End Operator

        Public Shared Operator <>(ByVal a As Binder, ByVal b As Binder) As Boolean
            If a Is Nothing Then
                If b Is Nothing Then Return False Else Return True
            End If

            Return Not a.Equals(b)
        End Operator

        Public MustOverride Overloads Function Equals(ByVal other As Binder) As Boolean _
            Implements System.IEquatable(Of Binder).Equals
    End Class

End Namespace